package com.mj.model
{
	import com.gamebase.net.rpc.IProtocolMap;
	import com.gamebase.net.rpc.baseTypeEx.int16;
	import com.mj.vo.AreaData;
	import com.mj.vo.Card;
	import com.mj.vo.RoleData;
	import com.mj.vo.SCGetMinLoadRes;
	import com.mj.vo.SCMJ2EnterRoomRes;
	import com.mj.vo.SCMJ2GangRes;
	import com.mj.vo.SCMJ2OutRoomRes;
	import com.mj.vo.SCMJ2WinRes;
	import com.mj.vo.SCNotifyMJ2Gang;
	import com.mj.vo.SCNotifyMJ2OutRoom;
	import com.mj.vo.SCNotifyMJ2WorldWin;
	
	public class ProtocolMap implements IProtocolMap
	{
		//----------------均衡负载-------------------------
		public static const BALANCE_CMD_0:int = 2;	// 均衡负载一级命令值 
		
		public static const CS_GET_MIN_LOAD_REQ:int = 3;		//负载查询请求
		public static const SC_GET_MIN_LOAD_RES:int = 4;		//负载查询请求
		
		//----------------网关命令-------------------------
		public static const GATEWAY_CMD_0:int = 4;	// gateway 服务器一级命令值 
		
		public static const CS_LOGIN_REQ:int = 1;		//登陆请求
		public static const SC_LOGIN_RES:int = 2;
		
		public static const CS_LOGOUT_REQ:int = 3;	//退出登陆 
		public static const SC_LOGOUT_RES:int = 4;	//
		
		public static const CS_GET_AREA_REQ:int = 5;	//获取大区列表的命令值
		public static const SC_GET_AREA_RES:int = 6;
		
		//----------------麻将游戏命令-------------------------
		public static const MJ2_CMD_0:int = 11;		// 二人麻将的一级命令值 
		
		public static const CS_MJ2_ENTER_ROOM_REQ:int =     1     // 请求进入房间 
		public static const SC_MJ2_ENTER_ROOM_RES:int =     2
		public static const SC_NOTIFY_MJ2_ENTER_ROOM:int =  3     // 通知其余玩家，有新人进来 
		
		public static const CS_MJ2_READY_REQ:int =      5     // 准备开始请求 
		public static const SC_MJ2_READY_RES:int =      6
		public static const SC_MJ2_NOTIFY_READY:int =   7
		
		public static const SC_NOTIFY_MJ2_BANKER:int =  36    // 定庄家 
		public static const SC_NOTIFY_MJ2_START_POS:int =   37    // 定抓牌位置 
		public static const SC_NOTIFY_MJ2_INIT_CARD:int =   38    // 开始时服务器下发抓牌信息 
		
		public static const CS_MJ2_GET_CARD_REQ:int =   8     // 请求抓牌
		public static const SC_MJ2_GET_CARD_RES:int =   9
		public static const SC_NOTIFY_MJ2_GET_CARD:int =10     // 通知其他玩家有人抓了牌 
		
		public static const CS_MJ2_PUT_CARD_REQ:int =   11     // 请求出牌 
		public static const SC_MJ2_PUT_CARD_RES:int =   12
		public static const SC_NOTIFY_MJ2_PUT_CARD:int =13    // 通知其他玩家有人出牌 
		
		public static const CS_MJ2_CHI_REQ:int =        14    // 请求吃牌 
		public static const SC_MJ2_CHI_RES:int =        15
		public static const SC_NOTIFY_MJ2_CHI:int =     16    // 通知其他玩家有人吃牌 
		
		public static const CS_MJ2_PENG_REQ:int =       17    // 碰牌请求 
		public static const SC_MJ2_PENG_RES:int =		18
		public static const SC_NOTIFY_MJ2_PENG:int =	19// 通知其他玩家有人碰牌 
		
		public static const CS_MJ2_GANG_REQ:int =  20// 杠请求 
		public static const SC_MJ2_GANG_RES:int =  21
		public static const SC_NOTIFY_MJ2_GANG_GET_CARD:int = 22;    // 
		public static const SC_NOTIFY_MJ2_GANG:int = 23    // 
		
		public static const CS_MJ2_TING_REQ:int =       24    // 听牌请求 
		public static const SC_MJ2_TING_RES:int =       25
		public static const SC_NOTIFY_MJ2_TING:int =    26
		
		public static const CS_MJ2_WIN_REQ:int =        27     // 胡牌请求 
		public static const SC_MJ2_WIN_RES:int =        28
		public static const SC_NOTIFY_MJ2_WIN:int =     29
		public static const SC_NOTIFY_MJ2_WORLD_WIN:int =   30
		
		public static const CS_MJ2_OUT_ROOM_REQ:int =   31;    // 退出房间请求 
		public static const SC_MJ2_OUT_ROOM_RES:int =   32;
		public static const SC_NOTIFY_MJ2_OUT_ROOM:int =33;
		
		//public static const REJECT_REQ:int = 4040;
		//public static const REJECT_PLAYERS_RSP:int = 4041;
		//public static const TIMEOUT_RSP:int = 4050;
		
		//----------------------------------other value-------------------------
		public static const MAX_OPENID_LEN:int =     32            // openid 最大长度 
		public static const MAX_OPENKEY_LEN:int =    48            // openkey 最大长度 
		
		public static const S_MALE:int =             0             // 男性 
		public static const S_FEMALE:int =           1             // 女性 
		
		public static const MAX_NAME_LEN:int =       64            // 名字字符串最长的长度 
		
		public static const MAX_PERSON_CARD_NUM:int =13            // 每个人最多的牌数 
		
		public static const MAX_MJ2_FAN_NUM:int =    32            // 番数最多的种类 
		public static const MAX_MJ2_TIME_NUM:int =   32            // 倍数最多的种类 
		
		public static const READY_STATE_NO:int =     0             // 还没准备好 
		public static const READY_STATE_YES:int =    1             // 已经准备好 
		public static const READY_STATE_NOBODY:int = 2;            // 还没人
		public static const T_GANG_AN:int = 0;
		public static const T_GANG_MING:int = 1;
		
		
		//-------------------------------------
		private var SCdataTypeMap:Object;							//socket响应和广播的回调的参数类型映射
		private static var _instance:ProtocolMap;
		
		public function ProtocolMap()
		{
			//TODO: implement function
			SCdataTypeMap = {
				(BALANCE_CMD_0+","+SC_GET_MIN_LOAD_RES):SCGetMinLoadRes ,
				(GATEWAY_CMD_0+","+SC_LOGIN_RES):RoleData ,
				(GATEWAY_CMD_0+","+SC_LOGOUT_RES):null ,	//null表示没有返回数据
				(GATEWAY_CMD_0+","+SC_GET_AREA_RES):(Vector.<AreaData>) ,
				(MJ2_CMD_0+","+SC_MJ2_ENTER_ROOM_RES):SCMJ2EnterRoomRes ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_ENTER_ROOM):RoleData ,
				(MJ2_CMD_0+","+SC_MJ2_READY_RES):null ,
				(MJ2_CMD_0+","+SC_MJ2_NOTIFY_READY):null ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_BANKER):(Vector.<int16>) ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_START_POS):(Vector.<int16>) ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_INIT_CARD):(Vector.<Card>) ,
				(MJ2_CMD_0+","+SC_MJ2_GET_CARD_RES):Card ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_GET_CARD):Card ,
				(MJ2_CMD_0+","+SC_MJ2_PUT_CARD_RES):null ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_PUT_CARD):Card ,
				(MJ2_CMD_0+","+SC_MJ2_CHI_RES):(Vector.<Card>) ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_CHI):(Vector.<Card>) ,
				(MJ2_CMD_0+","+SC_MJ2_PENG_RES):Card ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_PENG):Card ,
				(MJ2_CMD_0+","+SC_MJ2_GANG_RES):SCMJ2GangRes ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_GANG_GET_CARD):Card ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_GANG):SCNotifyMJ2Gang ,
				(MJ2_CMD_0+","+SC_MJ2_TING_RES):(Vector.<Card>) ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_TING):null ,
				(MJ2_CMD_0+","+SC_MJ2_WIN_RES):SCMJ2WinRes ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_WIN):SCMJ2WinRes ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_WORLD_WIN):SCNotifyMJ2WorldWin ,
				(MJ2_CMD_0+","+SC_MJ2_OUT_ROOM_RES):SCMJ2OutRoomRes ,
				(MJ2_CMD_0+","+SC_NOTIFY_MJ2_OUT_ROOM):SCNotifyMJ2OutRoom
				
				
			}
		}
		
		
		public function getType(typeId:String):Class
		{
			if(!SCdataTypeMap.hasOwnProperty(typeId))
				return null;
			
				
			return SCdataTypeMap[typeId];
		}
		
		public static function get instance():ProtocolMap
		{
			if(_instance == null)
				_instance = new ProtocolMap();
			return _instance;
		}
	}
}